﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TestPhotoPrinting
{
    public partial class FormPreviewing : Form
    {
        private Image _previewImage = null;
        public FormPreviewing(Image image)
        {
            _previewImage = image;
            InitializeComponent();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void FormPreviewing_Load(object sender, EventArgs e)
        {
            pictureBoxView.Image = _previewImage;
            //if (_previewImage != null)
            //{
            //    this.Size = _previewImage.Size;
            //}
            //buttonOK.Parent = pictureBoxView;
            //int x = (this.Size.Width - buttonOK.Width) / 2;
            //int y = this.Size.Height - 20 - buttonOK.Height;
            //buttonOK.Location = new Point(x, y);
        }

        private void FormPreviewing_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (pictureBoxView.Image != null)
            {
                pictureBoxView.Image.Dispose();
                pictureBoxView.Image = null;
            }
        }
    }
}
